from pysstv.color import MartinM1
 
from PIL import Image
 
def encode_sstv(image_path, output_audio_path):
 
    # 打开图片并预处理
 
    image = Image.open(image_path)
 
    if image.mode != 'RGB':
 
        image = image.convert('RGB')
 
    image = image.resize((320, 256))  # 调整分辨率
 
    
 
    # 创建编码器并生成音频
 
    sstv = MartinM1(image, 44100, 16)
 
    sstv.write_wav(output_audio_path)
 
    print(f"SSTV音频已保存到 {output_audio_path}")
 
# 使用示例
 
encode_sstv('./cat.png', 'output.wav')#修改为图片路径以及输出音频路径